<?php

// @formatter:off
/**
 * @file Class.php
 * @author Alejandro Dario Simi
 * @date $Date: 2014-06-03 03:40:32 +0000 (Tue, 03 Jun 2014) $
 *
 * $Id: Class.php 112 2014-06-03 03:40:32Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/trunk/extensions/AutoTagger/Class.php $
 */
define("WC_E_AUTOTAGGER_VERSION", "1.0");
define("WC_E_AUTOTAGGER_ROOTDIR", __DIR__);
define("WC_E_AUTOTAGGER_NAME", basename(WC_E_AUTOTAGGER_ROOTDIR));
define("WC_E_AUTOTAGGER_URI", dirname($_SERVER["SCRIPT_NAME"])."/{$wcPaths["extensions-directory-uri"]}/".WC_E_AUTOTAGGER_NAME);
define("WC_PERM_AUTOTAGGER", 10002);

$extensionBasicInfo = array(
	"name" => "Directories AutoTagger",
	"description" => "Apply tags to directories",
	"author" => "Alejandro Dario Simi",
	"version" => WC_E_AUTOTAGGER_VERSION,
	"url" => array(
		"title" => "wcomix:Extension:AutoTagger",
		"href" => "http://wiki.daemonraco.com/wiki/Wcomix:Extension:AutoTagger"
	)
);

$wcPaths["mvc"]["pools"]["actions"][] = __DIR__;
$wcPaths["mvc"]["pools"]["skins"]["actions"][] = __DIR__;
//
// Menu @{
function WC_E_AUTOTAGGER_MenuBuilder($code) {
	if($code == WC_MENU_CODE_ADMIN) {
		global $wcGroup;
		global $wcMenuItems;

		$wcMenuItems[WC_MENU_CODE_ADMIN]["middle"][] = array(
			"name" => "AutoTagger",
			"title" => "Directories AutoTagger",
			"ficon" => WC_E_AUTOTAGGER_URI."/icons/autotagger.png",
			"url" => "?action=autotagger:page&group={$wcGroup->id()}"
		);
	}
}
$wcMenuBuilders[] = "WC_E_AUTOTAGGER_MenuBuilder";
//@}

$auxDIR = substr(__DIR__, strlen($wcROOTDIR));
$wcDatabase["tables"][] = "{$auxDIR}/db/wc_autotagger.tab.xml";
$wcDatabase["indexes"][] = "{$auxDIR}/db/wc_autotagger.pk.xml";

$wcPermissions["pyramid-perms"]["ORGANIZER"][] = WC_PERM_AUTOTAGGER;
//
// Cron: @{
$wcCronScripts["CTAutoTagger"] = array_merge($extensionBasicInfo, array(
	"auto" => true,
	"enabled" => true,
	"class" => "AutoTaggerCron"
	));
foreach($wcCronProfiles as $profile => $list) {
	$aux = array();
	foreach($list as $item) {
		$aux[] = $item;
		if($item == "lists.update") {
			$aux[] = "CTAutoTagger";
		}
	}
	$wcCronProfiles[$profile] = $aux;
}
if(!in_array("CTAutoTagger", $wcCronProfiles[$wcCronProfile])) {
	$wcCronProfiles[$wcCronProfile][] = "CTAutoTagger";
}
// @}
//
// Loading cron.
// Warning: they only load when it is a shell execution.
// @{
if(defined("__SHELL__")) {
	include WC_E_AUTOTAGGER_ROOTDIR."/includes/AutoTaggerCron.php";
}
